import requests
from config import url, headers_web


class Group:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def get_group(cls, url: str, headers=headers_web, params=None):
        """
        Summary:班级信息查询
        Description:1.web学习材料调用 、 2、互动课堂
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/group"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_userstatistics(cls, url: str, headers=headers_web, params=None):
        """
        Summary:根据学年学期统计当前学期用户总数
        Description:1、数据可视化平台使用（本学期教学概览、本学期教学活动三级钻取）
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/groups/userstatistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_statistics(cls, url: str, headers=headers_web, params=None):
        """
        Summary:根据学年学期统计组数量
        Description:数据对接调用
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/groups/statistics"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_groups(cls, url: str, headers=headers_web, params=None):
        """
        Summary:获取所有组
        Description:数据对接调用
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/groups"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_group_simple_infos(cls, url: str, headers=headers_web, params=None):
        """
        Summary:根据班级信息Id查询班级详情
        Description:获取教室类型
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/groupmanagement/getgroupsimpleinfos"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_studentid(cls, url: str, headers=headers_web, params=None):
        """
        Summary:根据学生Id查询教学班信息
        Description:获取学生待办接口调用
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/v1/group/studentid"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_groupInfo(cls, url: str, headers=headers_web, params=None):
        """
        Summary:获取教学班信息
        Description:数据对接使用
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + "/courseApi/groupInfo"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def get_group_byID(cls, url: str, headers=headers_web, params=None, paramspath=None):
        """
        Summary:根据课程Id查询班级信息
        Description:web云课堂管理端使用
        :param url:
        :param headers:
        :param params:
        :return:
        """
        url = url + f"/courseApi/group/{paramspath}"
        r = requests.get(url=url, headers=headers, params=params)
        return r

    @classmethod
    def post_importclass(cls, url: str, headers=headers_web, data=None, file=None):
        """
        Summary:教学班信息批量导入
        Description:web云课堂管理端使用
        :param url:
        :param headers:
        :param data:
        :param file:
        :return:
        """
        url = url + "/courseApi/v1/groups/importclass"
        r = requests.post(url=url, headers=headers, data=data, files=file)
        return r

    @classmethod
    def post_batchdelete_groupmembers(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:批量删除班级学生信息
        Description:使用方：1、云课堂管理端-基础数据-班级学生信息
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/v1/groups/groupmembers/batchdelete"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_save_group_members(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:保存组及组成员
        Description:数据对接调用
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/v1/groups/groupmembers"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_batchdelete(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:批量删除班级信息
        Description:使用方：1、云课堂管理端-基础数据-班级信息
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/v1/groups/batchdelete"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_groupmanagement(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:班级信息查询
        Description:使用方：1、云课堂管理端-基础数据-班级信息
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/v1/groupmanagement"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_delgroup(cls, url: str, headers=headers_web, params=None, json=None, paramspath=None):
        """
        Summary:删除班级接口信息
        Description:云课堂调用
        :param url:
        :param headers:
        :param params:
        :param json:
        :param paramspath
        :return:
        """
        url = url + F"/courseApi/v1/group/{paramspath}"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_group(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:修改班级基本信息接口
        Description:使用方：1、云课堂管理端-基础数据-班级信息
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/v1/group"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_groupmembers(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:班级学生信息查询
        Description:使用方：1、云课堂管理端-基础数据-班级学生信息
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/groups/groupmembers"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_creategroup(cls, url: str, headers=headers_web, params=None, json=None):
        """
        Summary:创建班级接口
        Description:互动课堂调用
        :param url:
        :param headers:
        :param params:
        :param json:
        :return:
        """
        url = url + "/courseApi/group/creategroup"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r
